<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
  <title>学术</title>
  <style>
		html, body {width: 100%;min-height: 100%;background: #fff;}
    .h20 {height: 0.5rem;background: #f0f0f0;}


         /* 头部样式 */
         #thridHeader {
           padding-top: 25px;
           background: #2997e4;
         }
         .topbar {background: #2997e4; height:2rem; border-bottom: 1px solid #DDDFE3;}
         .topbar {background: #FF8400; height:2rem; border-bottom: 1px solid #DDDFE3;}
         .whitebar {background-color: #2997e4;}
         #thridHeader.tran > .whitebar {
           background: transparent;
         }
        .topbar {position:relative;}
         ul {display: -webkit-box; display: -webkit-flex; display: flex; }
         .back {float: left; }
         .back img {height: 1rem;margin-top: 0.5rem;margin-left: 0.75rem;}
         .topbar .title {line-height: 2rem;text-align: center;font-size: 1rem;color: #fff;}

        .topbar #text_r {position: absolute;right: 0;color: #fff;font-size: 0.8rem;margin: 0.5rem 0.75rem;bottom: 0;}

        .fbyh {
          padding: 0 1rem;
        }
        .fbyh input[type="text"] {
          font-size: 0.8rem;
          color: #333;
          border: none;
          border-bottom: 1px dashed #dcdcdc;
        }
        .fbyh h6 {
          color: #999;
          font-size: 0.8rem;
          line-height: 0.8rem;
          margin-top: 0.5rem;
        }
    .fbyh textarea {
      margin-top: 0.5rem;
      background: #ececec;
      width: 100%;
      padding: 0.5rem;
      height: 10rem;
    }
	</style>
</head>
<body>
  <div id="app">
    <!-- 第三头部 -->
    <div id="thridHeader" class="titlebar">
      <div class="topbar whitebar">
        <div class="back"  tapmode="" onclick="goback()"><img src="../../image/ic_back_u.png" alt=""></div>
        <div class="title" id="title">发布论文</div>
        <div id="text_r"  tapmode="" @click="Submit()">发布</div>
      </div>
    </div>
    <div class="fbyh">
      <input type="text" placeholder="请输入标题" v-model="title">
      <h6>请输入正文</h6>
      <textarea v-model="content"></textarea>
    </div>
</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript">

  function goback () {
    api.closeWin({name:api.pageParam.name});
  }

  apiready = function() {

		var app = new Vue({
			el: '#app',
			data: {
				title: '',
				content: '',
				token: '',
        type: ''
			},
			created: function() {
				var $_this = this;
        $_this.token = $api.getStorage('token') || '';
        $_this.type = api.pageParam.typeId

        if($_this.token == '') {
          alert('用户还未登录');
          return;
        }
			},
			methods: {
				 Submit: function() {
					 var $_this = this;
					 if($_this.title == '') {
             api.toast({ msg: '请输入论文标题',duration: 2000,location:'middle' });
	 					return
	 				} else if($_this.content == '') {
            api.toast({ msg: '请输入论文内容',duration: 2000,location:'middle' });
						 return
					 }
					 api.ajax({
 					  url: window.Url.addPaper,
						method: 'post',
				    headers: {
				        'Content-Type': 'application/json',
                'baseParams': $_this.token
				    },
						data: {
							body: {
								title: $_this.title,
								content: $_this.content,
                type: $_this.type
							}
						},
 						timeout: 300,
 					}, function(ret, err) {
 					    if (ret.message == "ok") {
							    api.openFrame({
							        name: 'fblw_succeed',
							        url: './fblw_succeed.html',
							        rect: {
							            x: 0,
							            y: 0,
							            w: 'auto',
							            h: 'auto'
							        },
                      bounces: false,
                      delay:200
							    });

 					    } else {
 					        api.alert({ msg: JSON.stringify(err) });
 					    }
 					})
				}

			}
		})
	}

</script>
</html>
